home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS01.ADF / ABasicStuff / Graphics / JPad.bas < prev    next >
BASIC Source File  |  1985-12-04  |  22KB  |  510 lines

  1. 10    ' jpad  version 1.00   originally titled skpad
  2. 11    '
  3. 12    ' This program should give you an idea of the kinds of graphic 
  4. 13    '  things you can do in ABASIC. Unfortunately this is not perfect
  5. 14    '  but it is FREE. Yes it's FREE. Please circulate.
  6. 15    ' 
  7. 16    ' Feel free to modify this program and put it backup on Compuserve.
  8. 17    ' 
  9. 18    ' This program will not save and load picture files correctly please
  10. 19    '  help me on this one. The disk menu is at 410 happy hacking.
  11. 20    '
  12. 21    ' jpad has no printer routine if you know how to do it please add it
  13. 22    '
  14. 23    'One other thing, this program eats memory! My amiga has the extra
  15. 24    ' 256k and I need more.
  16. 25    '
  17. 26    'That brings up a couple of real problems.
  18. 27    ' First cutting a full screen is not possible-memory constraints.
  19. 28    ' Second don't try to use screen top/bottom icons you'll get
  20. 29    '   an out of memory error.
  21. 30    ' 
  22. 31    ' Look for a lo-res version soon!
  23. 32    '
  24. 33    ' ******************************************************
  25. 34    ' 
  26. 35    'To use this program you need to point, click and sometimes drag.
  27. 36    '
  28. 37    'The choices from left to right on the screen are:
  29. 38    ' 16 color bars (far left) 
  30. 39    ' active color /color register window
  31. 40    ' eraser/clear screen icon
  32. 41    ' brush/pens and brushes window  icon
  33. 42    ' rubber band line icon
  34. 43    ' box outline icon
  35. 44    ' filled box icon
  36. 45    ' outline circle icon
  37. 46    ' filled circle icon
  38. 47    ' paint (roller) icon
  39. 48    ' cut (scissors) icon
  40. 49    ' paste (glue bottle) icon
  41. 50    ' and couple of empties for further mods
  42. 51    ' P / pattern window select icon
  43. 52    ' M / main menu icon (not much there, yet)
  44. 53    ' D / disk menu icon (buggy)
  45. 54    ' undo/don't undo icon (looks a diamond)
  46. 55    ' Q quit icon 
  47. 56    '
  48. 57    ' skpad by Rick Schaeffer
  49. 58    ' and modified by Jack Russell [ 74706.2406 ]
  50. 59    ' as of 11-16-85
  51. 60    '
  52. 61    ' THIS IS PUBLIC DOMAIN
  53. 62    '
  54. 63    scnclr:graphic(1):ask window s1%,s2%:if s1%<330 then screen 1,4,0
  55. 64    dim undo%(16002):dim undid%(16002):dim za%(3):dim zb%(3):dim zc%(7)
  56. 65    dim edit%(9702):dim checker%(1):dim tile%(7):dim crust%(7)
  57. 66    dim zd%(1):dim ze%(3):dim zf%(7):dim zg%(3):dim zh%(3):dim zi%(7):dim zj%(7):dim zk%(7)
  58. 67    za%(0)=34952:za%(1)=17476:za%(2)=8738:za%(3)=4369
  59. 68    zb%(0)=4369:zb%(1)=8738:zb%(2)=17476:zb%(3)=34952
  60. 69    zc%(0)=34952:zc%(1)=17476:zc%(2)=8738:zc%(3)=4369:zc%(4)=4369:zc%(5)=8738:zc%(6)=17476:zc%(7)=34952
  61. 70    zd%(0)=34952:zd%(1)=34952:ze%(0)=39321:ze%(1)=52428:ze%(2)=26214:ze%(3)=13107
  62. 71    zf%(0)=13107:zf%(1)=771:zf%(2)=64379:zf%(3)=64379:zf%(4)=771:zf%(5)=12336:zf%(6)=47031:zf%(7)=47031
  63. 72    zg%(0)=0:zg%(1)=30583:zg%(2)=30583:zg%(3)=30583:zh%(0)=34952:zh%(1)=65535:zh%(2)=34952:zh%(3)=65535
  64. 73    zi%(0)=0:zi%(1)=16383:zi%(2)=16383:zi%(3)=15363:zi%(4)=15363:zi%(5)=15363:zi%(6)=15363:zi%(7)=16383
  65. 74    zj%(0)=4112:zj%(1)=10280:zj%(2)=21588:zj%(3)=43690:zj%(4)=21588:zj%(5)=10280:zj%(6)=4112:zj%(7)=0
  66. 75    zk%(0)=30598:zk%(1)=39064:zk%(2)=63736:zk%(3)=63736:zk%(4)=30598:zk%(5)=35209:zk%(6)=36751:zk%(7)=36751
  67. 76    checker%(0)=43690:checker%(1)=21845
  68. 77    tile%(0)=65280:tile%(1)=65280:tile%(2)=65280:tile%(3)=65280
  69. 78    tile%(4)=255:tile%(5)=255:tile%(6)=255:tile%(7)=255
  70. 79    crust%(0)=3084:crust%(1)=16131:crust%(2)=65472:crust%(3)=16176
  71. 80    crust%(4)=3084:crust%(5)=12351:crust%(6)=49407:crust%(7)=831
  72. 81    ppa%=4:ppb%=2:ppo%=1:doit%=2:old%=2:pin%=1:pat%=1
  73. 82    b%=bb%=bbn%=bl%=blm%=0
  74. 83    ca=cr=cx%=cy%=g%=gn%=i=jump%=0
  75. 84    r%=rn%=s1%=s2%=w4%=0
  76. 85    x%=y%=x1%=y1%=x2%=y2%=0
  77. 86    qx=0:z$=""
  78. 87    pena ppa%:penb ppb%:peno ppo%
  79. 88    pattern 0,tile%()
  80. 89    paste%=1:dm%=1:drawmode dm%
  81. 90    x1%=-1:y1%=-1
  82. 91    ' set-up screen --------------------------------------
  83. 92    gosub 231:gosub 269:gosub 271
  84. 93    ' ================main================================
  85. 94    ask mouse x%,y%,b%:if b%=4 then 94
  86. 95    gosub 269
  87. 96    ask mouse x%,y%,b%
  88. 97    x1%=x%:y1%=y%
  89. 98    if b%=0 then 96
  90. 99    if y%<11 and b%=4 and x%<160 then 100 else 104
  91. 100   ppa%=int(x%*.1)
  92. 101   if ppa%<0 then ppa%=0
  93. 102   gosub 275:outline 0:pattern 0,tile%():box(163,0;187,12),1:gosub 251:outline 1
  94. 103   goto 96
  95. 104   if y%>14 then 126
  96. 105   if x%>163 and x%<187 then 277
  97. 106   if x%>190 and x%<210 and b%=4 and doit%<>1 then doit%=1:goto 94
  98. 107   if x%>190 and x%<210 and b%=4 and doit%=1 then outline 1:pattern 0,tile%():box(0,14;617,186),1:gosub 251:goto 95
  99. 108   if x%>210 and x%<230 and b%=4 and doit%<>2 then doit%=2:goto 94 else if x%>210 and x%<230 and b%=4 then 312
  100. 109   if x%>230 and x%<250 and b%=4 then doit%=3:goto 95
  101. 110   if x%>250 and x%<270 and b%=4 then doit%=4:goto 95
  102. 111   if x%>270 and x%<290 and b%=4 then doit%=5:goto 95
  103. 112   if x%>290 and x%<310 and b%=4 then doit%=6:goto 95
  104. 113   if x%>310 and x%<330 and b%=4 then doit%=7:goto 95
  105. 114   if x%>330 and x%<350 and b%=4 then doit%=8:gosub 269:goto 96
  106. 115   if x%>350 and x%<370 and b%=4 then doit%=9:goto 95
  107. 116   if x%>370 and x%<390 and b%=4 then doit%=10:goto 95
  108. 117   if x%>410  and x%<430 and b%=4 then ? at (320,100)fre:goto 96
  109. 118   if x%>510 and x%<530 and b%=4 then 361
  110. 119   if x%>530 and x%<550 and b%=4 then 394
  111. 120   if x%>550 and x%<570 and b%=4 then 410
  112. 121   if x%>570 and x%<590 and b%=4 and undo<>1 then gosub 127:undo=1:goto 96
  113. 122   if x%>570 and x%<590 and b%=4 and undo=1 then gosub 128:undo=0:goto 96
  114. 123   if x%>590 and x%<610 and b%=4 then 434
  115. 124   if y%<14 then 96
  116. 125   ' stash screen and go --------------------------------
  117. 126   undo=0:sshape(0,0;640,200),undo%():goto 129
  118. 127   sshape(0,0;640,200),undid%():gshape (0,0), undo%():gosub 267:return
  119. 128   gshape(0,0),undid%():gosub 267:return
  120. 129   on doit% gosub 157,131,164,177,188,192,207,190,209,226:goto 96
  121. 130   ' use pen or brush  ----------------------------------
  122. 131   outline 0:on pin% goto 132,133,134,135,136,137,138,139,140,141,142,143,144,147,152:return
  123. 132   draw(x1%,y1% to x%,y%):x1%=x%:y1%=y%:goto 153
  124. 133   area(x%,y% to x%+1,y% to x%+2,y%+1 to x%,y%+1 to x%,y%):goto 153
  125. 134   area(x%,y% to x%+6,y% to x%+6,y%+4 to x%,y%+4 to x%,y%):goto 153
  126. 135   area(x%,y% to x%+10,y% to x%+10,y%+6 to x%,y%+6 to x%,y%):goto 153
  127. 136   area(x%,y% to x%+10,y% to x%+10,y%+1 to x%,y%+1 to x%,y%):goto 153
  128. 137   area(x%,y% to x%+20,y% to x%+20,y%+1 to x%,y%+1 to x%,y%):goto 153
  129. 138   area(x%,y% to x%    *.[ch]          /* anything ending in .c or .h */
  130.  
  131. There are two routines:
  132.  
  133. First:
  134.  
  135.         int iswild(p)
  136.         char *p;        returns true if the string pointed to by p
  137.                         contains *, ? or [
  138.  
  139. Second:
  140.  
  141.   struct args
  142.     {
  143.         int argcount;
  144.         char **argvector;
  145.     } *ap,*expand();
  146.  
  147.    struct args *expand(p)
  148.    char *p;             returns a pointer to a structure as shown above
  149.                         containing a list of all the matching names.
  150.  
  151.                         Note: the names may contain full paths but the
  152.                         last specifier is file names only.  e.g. if
  153.                         you pass:
  154.  
  155.                                 a/b/c/* this will work but none of
  156.                                 the directories in c will be found
  157.  
  158.                                 a/b/*/* does not work!
  159.  
  160. These routines are available on object form only.  
  161.  
  162. Good luck,
  163. the folks at Tardis Software!
  164.  
  165. #endif
  166.  
  167. /* echox.c */
  168.  
  169. main(argc,argv)
  170. int argc;
  171. char **argv;
  172. {
  173.   int i,j;
  174.  
  175.   struct args
  176.     {
  177.         int argcount;
  178.         char **argvector;
  179.     } *ap,*expand();
  180.  
  181.   i = 1;
  182.   while(--argc)
  183.     {
  184.       printf("argv[%d] = \"%s\"\n",i,argv[i]);
  185.       if (iswild(argv[i]))
  186.         {
  187.           ap = expand(argv[i]);
  188.           printf("ap -> argcount = %d\n",ap -> argcount);
  189.           printf("ap -> argvector = %x\n",ap->argvector);
  190.           for(j=0; j < ap ->argcount; j++)
  191.             printf("argvector[%d]=\"%s\"\n",j,ap->argvector[j]);
  192.         }
  193.       i++;
  194.     }
  195. }
  196.  
  197.      case 0x3F2:     /* hunk_end */
  198.                                 if (debug)
  199.                                   printf("nxtsym= %d\n",nxtsym);
  200.                                 if (nxtsym)
  201.                                   putit(0xF0030000);      /* 000003f0 in 8086 order */
  202.                                 for(i = 0; i < nxtsym; i++)
  203.                                   {
  204.                                         /* put out symtable record?>=<;:98765k-Linkable object routines for echox.c routines ;Xexpand.o¢   ²τEXPANDΘ|NV Ç nJf4p■/HyN╣PÅ#└/N╣XÅ#└/N╣XÅ`d/.Hn ÇN╣PÅHn ÇN╣XÅAε ╤└ /fHn ÇN╣XÅAε ╤└Bp■/Hn ÇN╣PÅ#└/N╣XÅ#└p//<N╣PÅ#└//9N╣PÅN^Nu/9N╣XÅ/9N╣XÅNuNV °Hτ *n(n |. M╤╟"L╙╞░gJgRå`Φ|Rç`Γ L▀0└N^NuNV °Hτ *n(n |. L╤╞Jg("M╙╟░gRå`Φ|Rç M╤╟Jf┌ L▀0└N^Nu L▀0└N^NuNV °Hτ|╝« lf 9SÇ#└JÇkp yR╣`HyN╣XÅ.  Ç    gö Ç
  205. g Çf╩ SåJÇgSå`■ 9 SÇ#└ JÇk yR╣ Çr`Hy/N╣PÅ" SÇ n╤└ \f, n╤╞╝ `ó n╤╞B .L▀└N^Nu 9 SÇ#└ JÇk yR╣p Çr`Hyp /N╣PÅ" n╤╞╝ `D 9 SÇ#└ JÇk yR╣ Çr`Hy/N╣PÅ" n╤╞ ÇRå`■û/. HyHy0N╣O∩ `■vNV ⌠p-@ ⌠-@ ⁿ . ⁿ░«l£ nHÇH└-@ °J« ⌠fr8ük∞░╗f≡N√`╠\`ª"`n<`2>`*    `
  206.  `R«J« ⁿgå n B .N^N        typ = (j >> 24) & 0xFF;
  207.                                 j &= 0xFFFFFF;
  208.                                 normalize(&j);
  209.                                 lbuf = j;
  210.                                 if (debug)
  211.                                   printf("  hunk_symbol, typ=%d, len=%d\n",typ,lbuf);
  212.                                 switch(typ)
  213.                                   {
  214.                                         case 0: /* ext_def */
  215.                                                 for(i=0; i < lbuf; i++)
  216.                                                   {
  217.                                                     read(infile,&j,4);
  218.                                                     putit(j);
  219.                                                   }
  220.                                                 read(infile,&j,4); /* value */
  221.                                                 putit(j);
  222.                                                 break;
  223.                                   }
  224.                                 break;
  225.  
  226.                 case 0x3F2:     /* hunk_end */
  227.                                 if (debug)
  228.                                   printf("nxtsym= %d\n",nxtsym);
  229.                                 if (nxtsym)
  230.                                   putit(0xF0030000);      /* 000003f0 in 8086 order */
  231.                                 for(i = 0; i < nxtsym; i++)
  232.                                   {
  233.                                         /* put out symtable records */
  234.                                         putit(symhunk[i].len);
  235.                                         normalize(&symhunk[i].len);
  236.                                         if (debug)
  237.                                           printf("extsym len = %d\n",symhunk[i].len);
  238.  
  239.                                         for(j=0; j < symhunk[i].len; j++)
  240.                                           putit(symhunk[i].sym[j]);
  241.                                         putit(symhunk[i].value);
  242.                                   } 
  243.                                 if (nxtsym)
  244.                                   putit(0L);
  245.                                 nxtsym = 0;
  246.                                 putit(0xF2030000);
  247.                                 break;
  248.         }                       
  249.     }
  250.   if (debug)
  251.     printf("EOF detected\n");
  252.   close(infile);
  253.   close(f);
  254.   CopyItBack(fname);
  255. }
  256.  
  257. putit(l)
  258. unsigned long l;
  259. {
  260.   write(f,&l,4);
  261. }
  262.  
  263. normalize(lp)
  264. long *lp;
  265. {
  266.  
  267.   unsigned char hilo[4];
  268.   unsigned char lohi[4];
  269.  
  270.   BlockMove(lp,hilo,4);
  271.   lohi[0] = hilo[3];
  272.   lohi[1] = hilo[2];
  273.   lohi[2] = hilo[1];
  274.   lohi[3] = hilo[0];
  275.   BlockMove(lohi,lp,4);
  276. }
  277.  
  278.  
  279. BlockMove(p,q,l)
  280. unsigned char *p,*q;
  281. int l;
  282. {
  283.   while(l--)
  284.     *q++ = *p++;
  285. }
  286.  
  287. CopyItBack(fname)
  288. char *fname;
  289. {
  290.   int infile;
  291.   int f;
  292.   char buf[1024];       /* 1k at a time */
  293.   long l;
  294.  
  295.   infile = open("cnv.tmp",0);
  296.  
  297. #ifdef MSC30
  298.   f = creat(fname,S_IREAD | S_IWRITE);       /* assume binary mode */
  299. #endif
  300.  
  301. #ifdef LATTI
  302.   f = creat(fname, O_RAW | O_RDWR );       /* assume binary mode */
  303. #endif
  304.  
  305.  
  306.   while(1)
  307.     {
  308.       l = read(infile,buf,sizeof(buf));
  309.       if (l)
  310.         write(f,buf,l);
  311.       if (l != sizeof(buf))
  312.         break;
  313.     }
  314.   close(infile);
  315.   close(f);
  316.   unlink("cnv.tmp");
  317. }
  318.                         {
  319.                                     typ = (lbuf >> 24) & 0xFF;
  320.                                     lbuf &= 0xFFFFFF;
  321.                                     if (debug)
  322.                            -,+*)╧,Opposite of IBM dev. system CONVERT program. <(ⁿdecvnt.c¢   ²
  323. /* decvnt.c */
  324.  
  325. /****************************************************************/
  326. /*                                                              */
  327. /* program to reverse the operation of "convert" for the Amiga  */
  328. /* used to counteract the effect of BBS systems which can't take*/
  329. /* binary files                                                 */
  330. /* This program was originally compiled by Microsoft C 3.0      */
  331. /*      compile as:     msc decnvt;                             */
  332. /*      link as:        link decnvt+\msc\lib\binmode;           */
  333. /*                                                              */
  334. /* Copyright(c) 1985 Michael G. Lehman                          */
  335. /* Freely distribute but All Rights still reserved              */
  336. /*                                                              */
  337. /****************************************************************/
  338.  
  339. /* converted to Lattice by John Foust, the AMICUS Network */
  340.  
  341. /* define one of these */
  342. #define LATTI
  343. #undef MSC30
  344.  
  345. #include <stdio.h>
  346. #include <fcntl.h>
  347.  
  348. #ifdef MSC30
  349. #include <sys\types.h>
  350. #include <sys\stat.h>
  351. #include <io.h>
  352. #endif
  353.  
  354. char buf[256];
  355. unsigned char bytes[128];
  356.  
  357. FILE *in;
  358. int out;
  359.  
  360. main(argc,argv)
  361. int argc;
  362. char **argv;
  363. {
  364.   int i,j;
  365.   char *p;
  366.  
  367.   in = fopen(argv[1],"r");
  368.  
  369. #ifdef MSC30
  370.   out= open(argv[2],O_TRUNC | O_WRONLY | O_BINARY | O_CREAT , S_IWRITE);
  371. #endif
  372. #ifdef LATTI
  373.   out= open(argv[2],O_TRUNC | O_WRONLY | O_RAW | O_CREAT );
  374. #endif
  375.  
  376.   while(1) read(infile,&lbuf,4);
  377.                                     putit(lbuf);
  378.                                     normalize(&lbuf);
  379.                                     if (lbuf)
  380.                                       {
  381.                                         read(infile,&j,4);      /* hunk_number again */
  382.                                         putit(j);
  383.                                       }
  384.                                   }
  385.                                 break;
  386.  
  387.                 case 0x3EF:     /* hunk_ext */
  388.                                 read(infile,&lbuf,4);
  389.                                 putit(lbuf);
  390.                                 j = lbuf;
  391.                                 normalize(&lbuf);
  392.                                 while (lbuf)
  393.                                   {
  394.                                     typ = (lbuf >> 24) & 0xFF;
  395.                                     lbuf &= 0xFFFFFF;
  396.                                     if (debug)
  397.                                       printf("  hunk_ext, typ=%d, len=%d\n",typ,lbuf);
  398.                                     switch(typ)
  399.                                       {
  400.                                         case 1: /* ext_def */
  401.                                                 symhunk[nxtsym].len = j & 0xFFFFFF00;
  402.                                                 for(i=0; i < lbuf; i++)
  403.                                                   {
  404.                                                     read(infile,&j,4);
  405.                                                     putit(j);
  406.                                                     symhunk[nxtsym].sym[i] = j;
  407.                                                   }
  408.                                                 read(infile,&j,4); /* value */
  409.                                                 putit(j);
  410.                                                 symhunk[nxtsym].value = j;
  411.                                                 nxtsym++;
  412.                                                 break;
  413.  
  414.                                         case 2: /* ext_abs */
  415.                                         case 3: /* ext_res */
  416.                                                 for(i=0; i < lbuf; i++)
  417.                                                   {
  418.                                                     read(infile,&j,4);
  419.                                                     putit(j);
  420.                                                   }
  421.                                                 read(infile,&j,4); /* value */
  422.                                                 putit(j);
  423.                                                 break;
  424.                                         case 129: /* ext_ref32 */
  425.                                         case 131: /* ext_ref16 */
  426.                                         case 132: /* ext_ref8  */
  427.                                                 for(i=0; i < lbuf; i++)
  428.                                                   {
  429.                                                     read(infile,&j,4);
  430.                                                     putit(j);
  431.                                                   }
  432.                                                 read(infile,&lbuf,4); /* value */
  433.                                                 putit(lbuf);
  434.                                                 normalize(&lbuf);
  435.                                                 for(i=0; i < lbuf; i++)
  436.                                                   {
  437.                                                     read(infile,&j,4);
  438.                                                     putit(j);
  439.                                                   }
  440.                                                 break;
  441.                                         case 130: /* ext_common */               
  442.                                                 for(i=0; i < lbuf; i++)
  443.                                                   {
  444.                                                     read(infile,&j,4);
  445.                                                     putit(j);
  446.                                                   }
  447.                                                 read(infile,&j,4); /* size */
  448.                                                 putit(j);
  449.                                                 read(infile,&lbuf,4);
  450.                                                 putit(lbuf);
  451.                                                 normalize(&lbuf);
  452.                                                 for(i=0; i < lbuf; i++)
  453.                                                   {
  454.                                                     read(infile,&j,4);
  455.                                                     putit(j);
  456.                                                   }
  457.                                                 break;
  458.                                       }
  459.                                     read(infile,&lbuf,4);
  460.                                     putit(lbuf);
  461.                                     j = lbuf; 
  462.                                     normalize(&lbuf);
  463.                                   }
  464.                                 break;
  465.                 case 0x3F0:     /* hunk_symbol */
  466.                                 read(infile,&lbuf,4);
  467.                                 putit(lbuf);
  468.                                 j = lbuf;
  469.                                 normalize(&lbuf);
  470.                                 case '4':
  471.              c = '$';
  472.              break;
  473.           case '5':
  474.              c = '%';
  475.              break;
  476.           case '6':
  477.              c = '^';
  478.              break;
  479.           case '7':
  480.              c = '&';
  481.              break;
  482.           case '8':
  483.              c = '*';
  484.              break;
  485.           case '9':
  486.              c = '(';
  487.              break;
  488.           case '0':
  489.              c = ')';
  490.              break;
  491.           default:
  492.           } /* end switch */
  493.       } /* end shift */
  494.    else if (capsl && (c <= 'z') && (c >= 'a'))
  495.            c -= 32;
  496.    } /* end modifiers */
  497.    return(c);
  498. } /* end of routine */
  499. /* end of file */
  500.  
  501.                     if (sectcurr == (sectnum & 0xff))
  502.                         {
  503.                         emits("\nReceived Duplicate Sector\n");
  504.                         sendchar(ACK);
  505.                         }
  506.                     else
  507.                         errorflag = TRUE;
  508.                     }
  509.                 }
  510.         '&%$#"! 0╖2Fixes .o files so Wack can see external references <#objfix.c